<?php
/**
 * 
 * User/IndexAction.class.php (设计师模块)
 *
 * @package      	jgsat
 * @author          liuxun QQ:147613338 <admin@jgsat.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.jgsat.com)
 * @license         http://www.jgsat.com/license.txt
 * @version        	jgsat企业网站管理系统 v2.1 2012-10-08 jgsat.cn $
 */
if(!defined("JGsat")) exit("Access Denied");
class User_themeAction extends BaseAction
{

	function _initialize()
    {	
		parent::_initialize();
        $_GET =get_safe_replace($_GET);
       
       
        $this->dao = M('User');
        $this->assign('bcid',0);
        $user = $this->dao->find($this->_userid);
        $this->user=$user;
        $this->assign('vo',$user);
        $this->assign('title','个人中心');
		unset($_POST['status']);
		unset($_POST['groupid']);
		unset($_POST['amount']);
		unset($_POST['point']);

        
    }

    public function index()
    {
        $url_s='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

        $this->assign('url_s',$url_s);

        $this->Urlrule =F('Urlrule');
        $this->assign('title','我的帖子');
        if(empty($catid)) $catid =  intval($_REQUEST['id']);

        $plateid =  intval($_REQUEST['plateid']);
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);




            //print_r($num);exit;
        $where="userid=$this->_userid";
            $this->dao= M('Zforum_theme');
            $count = $this->dao->where($where)->count();
          //  echo $this->dao->getLastSql();exit;

            if($count){
                import ( "@.ORG.Page" );
                $listRows =  !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');

                $page = new Page ( $count, $listRows );
                $pages = $page->preshow();
                $field = '*';

                $order='createtime desc,id desc';

                $list = $this->dao->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select();
                //echo $this->dao->getLastSql();exit;

                $this->assign('pages',$pages);
                $this->assign('list',$list);
            }


        $_SESSION['rhemeurl']=$_SERVER['REQUEST_URI'];


        // echo  $_SESSION['rhemeurl'];exit;
//print_r( $list);exot;
        $this->display();


    }

    public function delete(){
    $id=$_GET['id'];
    $list=M('Zforum_theme')->field('userid')->where("id=".$id)->find();
    if($this->_userid!=$list['userid']){
        $this->error(L('出错啦'));
        exit;
    }
    $userid=$this->_userid;
    $dao= M('Zforum_theme');
    $result=$dao->where("id=".$id)->delete();
    M('User')->where('id='. $userid)->setDec('theme_num');
    if($result){
        $this->success('操作成功', $this->url);
    }

}

    public function message()
    {
        $url_s='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

        $this->assign('url_s',$url_s);

        $this->Urlrule =F('Urlrule');
        if(empty($catid)) $catid =  intval($_REQUEST['id']);

        $plateid =  intval($_REQUEST['plateid']);
        $p= max(intval($_REQUEST[C('VAR_PAGE')]),1);


        $where="userid=$this->_userid";
        $this->dao= M('Zforum_message');
        $count = $this->dao->where($where)->count();
        if($count){
            import ( "@.ORG.Page" );
            $listRows =  !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');

            $page = new Page ( $count, $listRows );
            $pages = $page->preshow();
            $field = '*';
            $order='createtime desc,id desc';
            $list = $this->dao->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select();
            $data['read']='1';
            $re=$this->dao->where("userid=".$this->_userid." and `read`=0")->save($data);

            $this->assign('pages',$pages);
            $this->assign('list',$list);
        }
        $_SESSION['rhemeurl']=$_SERVER['REQUEST_URI'];
        $this->display();
    }






}

